const text = document.getElementById("text");
const speed = document.getElementById("speed");
const content = "喜欢您，何需理由";
let index = 1;
let speedValue = 1330 / speed.value;

const typeWriter = () => {
	text.innerText = content.slice(0, index);
	index++;
	if (index > content.length) index = 1;
	setTimeout(typeWriter, speedValue);
};

typeWriter();

speed.addEventListener("input", (event) => (speedValue = 1330 / event.target.value));